﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BLL;
namespace 健身房管理
{
    public partial class 注册 : Form
    {
        public 注册()
        {
            InitializeComponent();
        }
        zhanghaoBLL zbl = new zhanghaoBLL();
        private void closebtn_Click(object sender, EventArgs e)
        {
            Login lg = new Login();
            lg.Show();
            this.Hide();
        }

        private void textBox1_Click(object sender, EventArgs e)
        {
            this.textBox1.BackColor = Color.White;
            panel3.BackColor = Color.White;
            panel4.BackColor = SystemColors.Control;
            this.textBox2.BackColor = SystemColors.Control;
        }

        private void textBox2_Click(object sender, EventArgs e)
        {
            this.textBox2.BackColor = Color.White;
            panel4.BackColor = Color.White;
            this.textBox1.BackColor = SystemColors.Control;
            panel3.BackColor = SystemColors.Control;
        }

        private void pictureBox3_MouseDown(object sender, MouseEventArgs e)
        {
            this.textBox2.UseSystemPasswordChar = false;
        }

        private void pictureBox3_MouseUp(object sender, MouseEventArgs e)
        {
            this.textBox2.UseSystemPasswordChar = true;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.textBox1.Text = "";
            this.textBox2.Text = "";
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataTable zcname = zbl.cxzh(this.textBox1.Text);    //zcname   注册用户名密码
            if (zcname.Rows.Count > 0)
            {
                MessageBox.Show("此账号已有人注册");
            }
            else
            {
                int isr = 0;
                 int usename =Convert.ToInt32 (this.textBox1.Text);
                int usepwd = Convert.ToInt32(this.textBox2.Text);
                
                    if (this.checkBox1.Checked)
                    {
                        //管理员
                        isr = 1;
                        bool b1 = zbl.zhzc(usename, usepwd, isr);
                        if (b1)
                        {
                            MessageBox.Show("注册成功");
                            MessageBox.Show("欢迎管理员");

                    }
                        else
                        {
                            MessageBox.Show("注册失败");
                        }
                    }
                    else
                    {
                        isr = 0;
                        bool b1 = zbl.zhzc(usename, usepwd, isr);
                        if (b1)
                        {
                            MessageBox.Show("注册成功");
                        }
                        else
                        {
                            MessageBox.Show("注册失败");
                        }
                    }               
            }
        }
    }
}
